home *** CD-ROM | disk | FTP | other *** search
- Path: newsfeed.internetmci.com!gatech!gt-news!news
- From: Darin Heuermann <gt1792a@prism.gatech.edu>
- Newsgroups: comp.lang.c++
- Subject: new and delete with arrays
- Date: 17 Feb 1996 13:38:18 GMT
- Organization: Virtual Software
- Message-ID: <4g4loa$i1l@mordred.gatech.edu>
- NNTP-Posting-Host: felix.cc.gatech.edu
- Mime-Version: 1.0
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- X-Mailer: Mozilla 1.22 (Windows; I; 32bit)
-
- When I allocate an array of classes with delete, should delete call all of
- the instances' destructors? Here is an example of what I mean.
-
- //**********************************************
-
- class MYCLASS {
- public:
- MYCLASS(void);
- ~MYCLASS(void);
- } // MYCLASS
-
- MYCLASS *myClass;
-
- myClass = new MYCLASS[10];
- delete myClass;
-
- //**********************************************
-
- I would expect all 10 instances to call ~MYCLASS() when delete myClass is
- called, but only the first instance's destructor is being called. Is the
- a bug in the compiler or is this how it's supposed to work?
-
- -- Darin Heuermann
- -- Virtual Software
-
-
-